import { Component, OnInit} from '@angular/core';
import { ApiService } from "@core/services/http/api.service";
import {Events} from "@core/services/events/Events";
import {ApesMessageService} from "@shared/apes/message";

@Component({
  selector: 'car-step',
  templateUrl: './car-step.component.html',
  styleUrls: ['./car-step.component.scss']
})
export class CarStepComponent implements OnInit{
  iconData:any[] = [];
  jjcdhNum:any;
  cphm: any;
  mdid: any;
  check:string = '1';

  constructor(private apiService:ApiService, private event:Events,
              private msg: ApesMessageService) {
  }

  ngOnInit() {
    this.getIcon();
  }

  getFun(key: string,cphm: string, mdid: string, checkKeys: string) {
    this.jjcdhNum = key;
    this.cphm = cphm;
    this.mdid = mdid;
    this.check = checkKeys;
    this.iconData = [];
    this.getIcon();
  }

  getIcon() {
    let data = {'interfaceMethod': 'ipmCLZKForAppService.getJCJC', 'pdata': {'JJCDH': this.jjcdhNum,'MDID': this.mdid, 'CPHM': this.cphm, 'ZT': this.check}};
    this.apiService.post('report.interface', {'body': JSON.stringify(data)}).subscribe(
      (resultData) => {
        const result = JSON.parse(resultData);
        if (result.success) {
          if (result.obj.length !== 0) {
            const data = JSON.parse(result.obj);
            this.iconData = data;
          }
        } else {
          this.msg.info(result.msg);
        }
      });
  }

}
